import axios from 'axios';

axios.defaults.baseURL = 'http://localhost:8086'

const axiosInstance = axios.create();

axiosInstance.interceptors.request.use((config) => {
    if(config.headers.Authorization === 'emp'){
        
        const token = localStorage.getItem("empToken");
        if (token) {
            config.headers.Authorization = `empToken${token}`;
        }
        return config;
    }
    
    const token = localStorage.getItem("userToken");
    if (token) {
        config.headers.Authorization = `${token}`;
    }
    return config;
}, (error) => {
    return Promise.reject(error);
});

export default axiosInstance;